package anthology.daily_question._25_01;
//https://leetcode.cn/problems/minimum-money-required-before-transactions/description/?envType=daily-question&envId=2025-01-25
public class _2412完成所有交易的初始最少钱数 {
    class Solution {
        public long minimumMoney(int[][] transactions) {
            long totalLose = 0;
            int res = 0;
            for (int[] t : transactions) {
                int cost = t[0];
                int cashback = t[1];
                totalLose += Math.max(cost - cashback, 0);
                res = Math.max(res, Math.min(cost, cashback));
            }
            return totalLose + res;
        }
    }
}
